﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace ExcelUtilities.Cfg
{
    /// <summary>
    /// 列配置信息
    /// </summary>
    public class Column
    {
        /// <summary>
        /// 获取或设置列名（作为列的标识）
        /// </summary>
        [XmlAttribute]
        public string Name { get; set; }

        int _order;
        /// <summary>
        /// 列号（从1开始）
        /// </summary>
        [XmlAttribute]
        public int Order
        {
            get { return _order; }
            set
            {
                _order = value;
                _address = _order.ToAddr();
            }
        }

        string _address;
        /// <summary>
        /// 列名（如A）
        /// </summary>
        [XmlAttribute]
        public string Address
        {
            get { return _address; }
            set
            {
                _address = value;
                _order = _address.ToPos().Col;
            }
        }

        /// <summary>
        /// 列数据类型
        /// </summary>
        [XmlAttribute]
        public string DataType { get; set; }

        /// <summary>
        /// 判断该列单元格内容是否匹配的正则表达式
        /// 用于确定是否读取当前行
        /// </summary>
        [XmlAttribute]
        public string Mark { get; set; }
        /// <summary>
        /// 判断该列单元格内容是否匹配的正则表达式
        /// 用于确定读取的起始行
        /// </summary>
        [XmlAttribute]
        public string StartMark { get; set; }
        /// <summary>
        /// 判断该列单元格内容是否匹配的正则表达式
        /// 用于确定读取的结束行
        /// </summary>
        [XmlAttribute]
        public string EndMark { get; set; }
        /// <summary>
        /// 单元格内容验证不正确的错误提示内容
        /// </summary>
        [XmlAttribute]
        public string ErrorMessage { get; set; }
    }
}